<?php
/**
 * main.php
 * @author ranuandra
 *
 * 9 Agu 2011 08:42:57
 *
 * 
 */
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>NASMOCO</title>
<link href="<?php echo URL::base()?>assets/css/style.css" rel="stylesheet" type="text/css" />
<link href="<?php echo URL::base()?>assets/css/template.css" rel="stylesheet" type="text/css" />
<link href="<?php echo URL::base()?>assets/css/form.css" rel="stylesheet" type="text/css" />
<link href="<?php echo URL::base()?>assets/css/sort.css" rel="stylesheet" type="text/css" />
<link href="<?php echo URL::base()?>assets/css/jquery.multiselect.css" rel="stylesheet" type="text/css" />
<link href="<?php echo URL::base()?>assets/css/jquery.multiselect.filter.css" rel="stylesheet" type="text/css" />
<link href="<?php echo URL::base()?>assets/css/ui-lightness/jquery-ui-1.8.16.custom.css" rel="stylesheet" type="text/css" />


<link rel="stylesheet" type="text/css" href="<?php echo URL::base()?>assets/css/superfish.css" media="screen">
<link rel="stylesheet" type="text/css" href="<?php echo URL::base()?>assets/js/fancybox/jquery.fancybox-1.3.4.css" media="screen" />
<script type="text/javascript" src="<?php echo URL::base()?>assets/js/jquery-1.2.6.min.js"></script>
<script type="text/javascript" src="<?php echo URL::base()?>assets/js/jquery-ui-1.8.16.custom.min.js"></script>
<script type="text/javascript" src="<?php echo URL::base()?>assets/js/jquery.form.js"></script>
<script type="text/javascript" src="<?php echo URL::base()?>assets/js/hoverIntent.js"></script>
<script type="text/javascript" src="<?php echo URL::base()?>assets/js/superfish.js"></script>
<script type="text/javascript" src="<?php echo URL::base()?>assets/js/fancybox/jquery.mousewheel-3.0.4.pack.js"></script>
<script type="text/javascript" src="<?php echo URL::base()?>assets/js/fancybox/jquery.fancybox-1.3.4.pack.js"></script>
<script type="text/javascript" src="<?php echo URL::base()?>assets/js/view.js"></script>
<script type="text/javascript" src="<?php echo URL::base()?>assets/js/jquery.tablesorter.min.js"></script>
<script type="text/javascript" src="<?php echo URL::base()?>assets/js/FusionCharts.js"></script>
<script type="text/javascript" src="<?php echo URL::base()?>assets/js/center.js"></script>
<script type="text/javascript" src="<?php echo URL::base()?>assets/js/jquery.multiselect.min.js"></script>
<script type="text/javascript" src="<?php echo URL::base()?>assets/js/jquery.multiselect.filter.min.js"></script>
<script type="text/javascript" src="<?php echo URL::base()?>assets/js/jquery.tools.min.js"></script>

<script type="text/javascript"><!--
	/*$(function() {
	    $(this).bind("contextmenu", function(e) {
	        e.preventDefault();
	    });
	});*/
	$(document).ready(function() {
		var html = '<img src="<? echo URL::base();?>assets/images/loader.gif" alt="Loading..." title="Loading..." >';
		var horloader = '<img src="<? echo URL::base();?>assets/images/hor_loader.gif" alt="Loading..." title="Loading..." class="horloader" >';
		var olay = '<div class="overlay"></div>';
		$('ul.sf-menu').superfish();
		$('.clsform').live('mouseover', function(){ $(this).fancybox()});
		$('.clsform').live('click', function(){
			$(this).fancybox({
				'opacity'				: true,
				'overlayShow'			: true,
				'hideOnOverlayClick'	: false,
				'hideOnContentClick'	: false,
				'transitionIn'			: 'elastic',
				'transitionOut'			: 'none',
				'width'					: 100
			});
			
		});
		$('.loader').hide();
		$('.loader').html(html);
		$('.loader').fixedCenter();
		//$('.loader').html(html);
		//$('.loader').center();
		$('.topmenu').live('click', function(){
			$('<div class="overlay"></div>').appendTo('.contain');
			$('.loader').html(html);
			$('.loader').show();
			var link = $(this).attr('href');
			$('.contain').load(link, function(response, status, xhr){
				if(status=='error')
				{
					alert("Terjadi kesalahan" + xhr.status + " " + xhr.statusText);
				}
				$('.contain').slideDown();
				$('.loader').hide();
				
				$('#selmodel').multiselect({
					close: function()
						{
							$('#selopt_type').empty();
				            $(horloader).appendTo('#selopt_type');
							$.ajax({
								   type: "POST",
								   url: "<?php echo URL::base()?>report/typelist",
								   data: "merk="+$("select#selmerk").val()+"&model="+$("select#selmodel").val(),
								   success: function(msg){
									   $('#selopt_type').html(msg);
									   $('#seltype').multiselect().multiselectfilter();
									   
								   }
								 });
						}
					}).multiselectfilter();

				$('#selmerk').multiselect({
					close: function()
					{
						
						//var coba = $("select#selmerk").val();
						//alert(coba);
						$('#selopt_type').empty();
		                $(horloader).appendTo('#selopt_type');
						$.ajax({
							   type: "POST",
							   url: "<?php echo URL::base()?>report/typelist",
							   data: "merk="+$("select#selmerk").val()+"&model="+$("select#selmodel").val(),
							   success: function(msg){
								   $('#selopt_type').html(msg);
								   $('#seltype').multiselect().multiselectfilter();
							   }
							 });

					}
				}).multiselectfilter();

				$('select#sglsel').multiselect({
					multiple: false
				}).multiselectfilter();

				$('#seltype').multiselect().multiselectfilter();

				$('#selarea').multiselect().multiselectfilter();

				var dates = $( "#from, #to" ).datepicker({
					defaultDate: "+1w",
					changeMonth: true,
					numberOfMonths: 3,
					onSelect: function( selectedDate ) {
						var option = this.id == "from" ? "minDate" : "maxDate",
							instance = $( this ).data( "datepicker" ),
							date = $.datepicker.parseDate(
								instance.settings.dateFormat ||
								$.datepicker._defaults.dateFormat,
								selectedDate, instance.settings );
						dates.not( this ).datepicker( "option", option, date );
					}
				});
				
			});
			return false;
		});
		
		$('.selopt_merk').live('change', function(){
				var link = $(this).attr('target');
				$('.selopt_type').empty();
				$(horloader).appendTo('.selopt_type');
				$('.selopt_type').load(link+"/"+$(this).val(), function(response, status, xhr){
					if(status=="success")
					{
						$('.horloader').remove();
						$('select.seltype').multiselect();
					}
				});
			});

		$('select#sglsel').multiselect({
			multiple: false
		});

		$(".tip").tooltip();

		$('.formdata').live('submit',function(){
			var targetdata = $(this).attr('targetdata');
			var targeturl = $(this).attr('targeturl');
        	$(this).ajaxSubmit({
    			success: function(data){
        			if(data!="sukses")
        			{
    					$(targetdata).html(data).fadeIn();
    					$(".tips").tooltip();
        			}
        			else
        			{
            			$('.tbldata').load('<?php echo URL::base()?>'+targeturl);
        				$.fancybox.close();
        			}
        	     }
        	});
			return false;
		});

		$('.linkajax').live('click', function(){
				$('<div class="overlay"></div>').appendTo('.contain');
				var targetdata = $(this).attr('targetdata');
				var refid = $(this).attr('refid');
				var targeturl = $(this).attr('href');

				var type = $("select#seltype").val();
				if(type==undefined)
				{
					type="";
				}

				var merk = $("select#selmerk").val();
				if(merk==undefined)
				{
					merk="";
				}
				var model = $("select#selmodel").val();
				if(model==undefined)
				{
					model="";
				}
				
				$.ajax({
					   type: "POST",
					   url: targeturl,
					   data: "customer="+refid+"&type_id="+type+"&merk="+merk+"&model_id="+model,
					   success: function(msg){
						   $(targetdata).html(msg);
							$('#selmodel').multiselect({
								close: function()
									{
										$('#selopt_type').empty();
							            $(horloader).appendTo('#selopt_type');
										$.ajax({
											   type: "POST",
											   url: "<?php echo URL::base()?>report/typelist",
											   data: "merk="+$("select#selmerk").val()+"&model="+$("select#selmodel").val(),
											   success: function(msg){
												   $('#selopt_type').html(msg);
												   $('#seltype').multiselect().multiselectfilter();
												   
											   }
											 });
									}
								}).multiselectfilter();

							$('#selmerk').multiselect({
								close: function()
								{
									
									//var coba = $("select#selmerk").val();
									//alert(coba);
									$('#selopt_type').empty();
					                $(horloader).appendTo('#selopt_type');
									$.ajax({
										   type: "POST",
										   url: "<?php echo URL::base()?>report/typelist",
										   data: "merk="+$("select#selmerk").val()+"&model="+$("select#selmodel").val(),
										   success: function(msg){
											   $('#selopt_type').html(msg);
											   $('#seltype').multiselect().multiselectfilter();
										   }
										 });

								}
							}).multiselectfilter();

							$('select#sglsel').multiselect({
								multiple: false
							}).multiselectfilter();

							$('#seltype').multiselect().multiselectfilter();

							$('#selarea').multiselect().multiselectfilter();

							var dates = $( "#from, #to" ).datepicker({
								defaultDate: "+1w",
								changeMonth: true,
								numberOfMonths: 3,
								onSelect: function( selectedDate ) {
									var option = this.id == "from" ? "minDate" : "maxDate",
										instance = $( this ).data( "datepicker" ),
										date = $.datepicker.parseDate(
											instance.settings.dateFormat ||
											$.datepicker._defaults.dateFormat,
											selectedDate, instance.settings );
									dates.not( this ).datepicker( "option", option, date );
								}
							});
					   }
					 });

				return false;
		});

		$('.searchdata').live('submit',function(){
			var targetdata = $(this).attr('targetdata');
			var targeturl = $(this).attr('targeturl');
			$('<div class="overlay"></div>').appendTo('.tbldata');
			$('.loader').html(html);
			$('.loader').show();
        	$(this).ajaxSubmit({
    			success: function(data){
    				$(targetdata).html(data).fadeIn();
    				$('.contain').slideDown();
    				$('.loader').hide();
    				$(".data").tablesorter();
    				$(".data");
    				$(".tip").tooltip();
        	     }
        	});
			return false;
		});

		$(".data").tablesorter();
		$('#selmodel').multiselect({
			close: function()
				{
					$('#selopt_type').empty();
		            $(horloader).appendTo('#selopt_type');
					$.ajax({
						   type: "POST",
						   url: "<?php echo URL::base()?>report/typelist",
						   data: "merk="+$("select#selmerk").val()+"&model="+$("select#selmodel").val(),
						   success: function(msg){
							   $('#selopt_type').html(msg);
							   $('#seltype').multiselect().multiselectfilter();
						   }
						 });
				}
			}).multiselectfilter();
		$('#selmodel').live('mouseover', function(){ $(this).multiselect()});

		$('#seltype').multiselect().multiselectfilter();
		$('#seltype').live('mouseover', function(){ $(this).multiselect()});

		$('#selmerk').multiselect({
			close: function()
			{
				
				//var coba = $("select#selmerk").val();
				//alert(coba);
				$('#selopt_type').empty();
                $(horloader).appendTo('#selopt_type');
				$.ajax({
					   type: "POST",
					   url: "<?php echo URL::base()?>report/typelist",
					   data: "merk="+$("select#selmerk").val()+"&model="+$("select#selmodel").val(),
					   success: function(msg){
						   $('#selopt_type').html(msg);
						   $('#seltype').multiselect().multiselectfilter();
					   }
					 });

			}
		}).multiselectfilter();
		$('#selmerk').live('mouseover', function(){ $(this).multiselect({
					click: function(event, ui)
					{
						alert(ui.value);
					}

		})});

		$('#selarea').multiselect().multiselectfilter();
		$('#selarea').live('mouseover', function(){ $(this).multiselect()});
		

		var dates = $( "#from, #to" ).datepicker({
			defaultDate: "+1w",
			changeMonth: true,
			numberOfMonths: 3,
			onSelect: function( selectedDate ) {
				var option = this.id == "from" ? "minDate" : "maxDate",
					instance = $( this ).data( "datepicker" ),
					date = $.datepicker.parseDate(
						instance.settings.dateFormat ||
						$.datepicker._defaults.dateFormat,
						selectedDate, instance.settings );
				dates.not( this ).datepicker( "option", option, date );
			}
		});
	});



		--></script>
</head>

<body>
<div class="container container_12">
<div class="grid_12 top">
	<div class="header-inside"> 
		<div class="logo">
			<img src="<?php echo URL::base()?>assets/images/logo.jpg" alt="" />
		</div>
    	<div class="anim">
          <object id="FlashID" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="300" height="100">
            <param name="movie" value="<?php echo URL::base()?>assets/swf/logo.swf" />
            <param name="quality" value="high" />
            <param name="wmode" value="opaque" />
            <param name="swfversion" value="6.0.65.0" />
            <!-- This param tag prompts users with Flash Player 6.0 r65 and higher to download the latest version of Flash Player. Delete it if you don’t want users to see the prompt. -->
            <param name="expressinstall" value="Scripts/expressInstall.swf" />
            <!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. -->
            <!--[if !IE]>-->
            <object type="application/x-shockwave-flash" data="<?php echo URL::base()?>assets/swf/logo.swf" width="300" height="100">
              <!--<![endif]-->
              <param name="quality" value="high" />
              <param name="wmode" value="opaque" />
              <param name="swfversion" value="6.0.65.0" />
              <param name="expressinstall" value="Scripts/expressInstall.swf" />
              <!-- The browser displays the following alternative content for users with Flash Player 6.0 and older. -->
              <div>
                <h4>Content on this page requires a newer version of Adobe Flash Player.</h4>
                <p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>
              </div>
              <!--[if !IE]>-->
            </object>
            <!--<![endif]-->
          </object>
    	</div>
    </div>
</div>
<?php 
if(isset($menu))
{
?>
<div class="grid_12 menu">
		<?php echo $menu;	 ?>           
</div>
<?php 
}
?>
<div class="grid_12">
	<div class="middle">
    	<div class="inside">
			<div class="loader"></div>
			<div class="contain">
			<?php
			if(isset($title))
			{
			?>
				<!--  <div class="grid_12 title_header">
					<?php echo $title;	 ?>
				</div>-->
			<?php 
			}
			?>
				<div class="grid_12 main_container">
	        <?php 

	         if(isset($container))
	         {
	             echo $container;	
	          }
	       	 ?>
	       	 	</div>
       		</div>
    	</div>
    </div>
</div>
<div class="grid_12 footer">
    	<div class="inside">
			PT NEW RATNA MOTOR @2011
    	</div>
</div>
</div>
</body>
</html>